#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>

int main(){
	int pid;
	int fd;
	printf("About to run who into a file\n");
	
	if((pid = fork()) == -1){
		perror("fork");
		exit(1);
	}
	
	if(pid == 0){
		close(1);
		fd = open("userlist",O_RDWR);
		execlp("who","who",NULL);
		perror("execlp");
		exit(1);
	}
	
	if(pid!=0){
		wait(0);
		printf("Done runing who. result in userlist.\n");
	}
	
	return 0;
}